package com.mangowang.module.main.adapter;



import android.content.Context;
import android.graphics.Color;


import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.mangowang.lib.common.proto.Order;
import com.mangowang.module.main.R;
import com.mangowang.module.main.bean.ShopOrderBean;
import com.ruffian.library.widget.RTextView;

import java.util.List;

public class ShopOrderAdapter extends BaseMultiItemQuickAdapter<ShopOrderBean, BaseViewHolder>  implements LoadMoreModule {
    public ShopOrderAdapter(Context context, List<ShopOrderBean> dataList) {
        super(dataList);
        addItemType(0, R.layout.item_title_shop);
        addItemType(1, R.layout.item_shop_order);
        addItemType(2, R.layout.item_shop_line);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopOrderBean item) {
        // 根据返回的 type 分别设置数据
        switch (helper.getItemViewType()) {
            case 0:
                RTextView typeView = helper.getView(R.id.tv_type);
                Order.order_detail order =  item.getTitle_item();
                if (order.getType().equals("1"))  // 划入
                {
                    typeView.setText("商城入库");
                    typeView.getHelper().setBackgroundColorNormal(Color.parseColor("#FFE8EFFA"));
                    typeView.setTextColor(Color.parseColor("#FF4863F0"));
                    helper.setText(R.id.tv_name,  "收到: " + order.getName() );
                } else {
                    typeView.setText("退货出库");
                    typeView.getHelper().setBackgroundColorNormal(Color.parseColor("#FFFEE9D4"));
                    typeView.setTextColor(Color.parseColor("#FFFB9028"));
                    helper.setText(R.id.tv_name,  "退货给: " + order.getName());
                }
                helper.setText(R.id.tv_time,"划拨日期 " + order.getCreatedTime());
                break;
            case 1:
                Order.order_info_item info =  item.getItem();
                helper.setText(R.id.tv_goods_name, info.getGoodsName() + " " + info.getGoodsSerial() )
                        .setText(R.id.tv_number,info.getNum()+"台");
                break;
            default:
                break;
        }
    }
}